package com.ls.pattern.behavior.iterator;

import java.util.Iterator;

//计算机学院迭代器
public class ComputerCollegeIterator  implements Iterator {
    Department[] department;
    int position = 0;//遍历的位置

    public ComputerCollegeIterator(Department[] department) {
        this.department = department;
    }

    @Override
    public boolean hasNext() {
        if (position >= department.length|| department[position] == null){
            return false;
        }
        return true;
    }

    @Override
    public Object next() {
        return department[position++];
    }

    //默认空实现
    @Override
    public void remove() {

    }
}
